<?php

namespace Ignus\View\Node;

use Ignus\View\Node;
use Ignus\View\Compiler;
use Ignus\View\NodeOutputInterface;

class PrintNode extends Node implements NodeOutputInterface
{
    public function __construct(Expression $expr, $lineno, $tag = null)
    {
        parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
    }

    public function compile(Compiler $compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write('echo ')
            ->subcompile($this->getNode('expr'))
            ->raw(";\n");
    }
}
